#ifndef __ZEN_MODEL_HPP__
#define __ZEN_MODEL_HPP__

#include <set>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string.hpp>
#include <JSL.hpp>

#include "../defines.hpp"
#include "ShaderManager.hpp"

#include "model/Definition.hpp"

namespace zen {

	namespace video {

		class Model {

		public:

			std::string name;
			glm::mat4 view;

			Model(model::PDefinition definition);
			Model(const Model &model);
			~Model();

			Model& operator = (const Model &other);

			model::PDefinition getDefinition() const { return definition; };
			
			model::Mesh* getMesh(glm::uint meshIndex) const { return (*definition).getMesh(meshIndex); };

			model::Bone* getBone(glm::uint boneIndex) const { return (*definition).getBone(boneIndex); };
			model::Bone* getBone(const std::string &boneName) const { return (*definition).getBone(boneName); };
			
			model::Mesh* getMeshByBone(glm::uint boneIndex) const { return (*definition).getMeshByBone(boneIndex); };
			model::Mesh* getMeshByBone(const std::string &boneName) const { return (*definition).getMeshByBone(boneName); };

			void update(int interval);
			void draw() const;

			void setAllBonesAnimationFrame(glm::uint start, glm::uint end, glm::uint position, model::AnimType type = model::AnimTypeNone, glm::float32 speed = 1.0);
			void setBoneAnimationFrame(glm::uint boneIndex, glm::uint start, glm::uint end, glm::uint position, model::AnimType type = model::AnimTypeNone, glm::float32 speed = 1.0);

			
		private:

			model::PDefinition definition;
			glm::uint boneCount;
			model::Bone** bones;

		};


		typedef ptr(Model) PModel;


	} // namespace video

} // namespace zen

#endif // __ZEN_MODEL_HPP__
